﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using RevitInteractiveUtility.ExternalEventManager;

namespace SampleAndTest.ExternalEventManager.SingleFromDemo
{
	public partial class SingleForm : System.Windows.Forms.Form
	{
		public SingleForm(ExternalCommandData cmdData)
		{
			this.m_cmdData = cmdData;
			this.InitializeComponent();
			this.InitExternalEventRequest();
		}

		private void InitExternalEventRequest()
		{
			ExternalEventManagerSingleton eventManger = ExternalEventManagerSingleton.GetEventManger(false);
			int iRequestId = 1;
			this.m_RequestA = new SingleFormRequestA(iRequestId);
			int iRequestId2 = 2;
			this.m_RequestB = new SingleFormRequestB(iRequestId2);
			eventManger.AppendRequest(this.m_RequestA);
			eventManger.AppendRequest(this.m_RequestB);
		}

		private void button1_Click(object sender, EventArgs e)
		{
			Document document = this.m_cmdData.Application.ActiveUIDocument.Document;
			ExternalEventManagerSingleton eventManger = ExternalEventManagerSingleton.GetEventManger(false);
			int keyValue = 1;
			ModelLineData modelLineData = new ModelLineData();
			modelLineData.GeoCv = Line.CreateBound(XYZ.Zero, new XYZ(100.0, 100.0, 0.0));
			modelLineData.GeoPlane = RevitVersionFuncs.CreatePlanByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero);
			modelLineData.Doc = document;
			eventManger.DoRequest(keyValue, this.m_cmdData.Application, modelLineData);
		}

		private void button2_Click(object sender, EventArgs e)
		{
			ExternalEventManagerSingleton eventManger = ExternalEventManagerSingleton.GetEventManger(false);
			int keyValue = 2;
			eventManger.DoRequest(keyValue, this.m_cmdData.Application, this.m_cmdData.Application);
		}

		private ExternalCommandData m_cmdData;

		private SingleFormRequestA m_RequestA;

		private SingleFormRequestB m_RequestB;

		private enum ERequestId
		{
			eTransactionA = 1,
			eTransactionB,
			eNoOper
		}
	}
}
